import axiosInstance from "./axiosInstance";
import qs from "qs";
const API = {
    foods : {
        getFoodsList(){
            return axiosInstance.get("/myxj/food?method=list");
        },
        getFoodsDetailById(fid){
            return axiosInstance.get("/myxj/food?method=foodDetails",{
                params:{
                    fid
                }
            });
        },
        getFoodsListByFname(fname){
            return axiosInstance.get("/myxj/food?method=search",{
                params:{
                    fname
                }
            })
        }
    },
    classify: {
        getClassifyList(){
            return axiosInstance.get("/myxj/category?method=list");
        }
    },
    user:{
        checkLogin({sno,password}){
            return axiosInstance.get("/myxj/user?method=login",{
                params:{
                    sno,password
                }
            });
        }
    },
    comments:{
        getFoodsComments(fid){
            return axiosInstance.get("/myxj/comment?method=foodComment",{
                params:{
                    fid
                }
            })
        },
        publishedComment(fid,oid,sno,cont){
            return axiosInstance.post("/myxj/comment?method=writeComment",qs.stringify({
                fid,oid,sno,cont
            }));
        }
    },
    order:{
        createOrder(encodestr){
            return axiosInstance.post("/myxj/order?method=create",qs.stringify({
                shoppingCart:encodestr
            }));
        },
        getOrderList(sno){
            return axiosInstance.get("/myxj/order?method=my",{
                params:{
                    sno
                }
            });
        },
        getOrderDetailByOid(oid){
            return axiosInstance.get("/myxj/order?method=details",{
                params:{
                    oid
                }
            });
        }
    }
}

export default API;